home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for NON-COMMERCIAL purposes and without
- * fee is hereby granted provided that this copyright notice
- * appears in all copies. Please refer to the file "LICENSE"
- * for further important copyright and licensing information.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
- *
- * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
- * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
- * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
- * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
- * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
- * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
- * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). SUN
- * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
- * HIGH RISK ACTIVITIES.
- */
-
- package java.sql;
-
- /**
- * <P>When JDBC unexpectedly truncates a data value, it reports a
- * DataTruncation warning (on reads) or throws a DataTruncation exception
- * (on writes).
- *
- * <P>The SQLstate for a DataTruncation is "01004".
- */
-
- public class DataTruncation extends SQLWarning {
-
- /**
- * <P>Create a DataTruncation object. The SQLState is initialized
- * to 01004, the reason is set to "Data truncation" and the
- * vendorCode is set to the SQLException default.
- *
- * @param index The index of the parameter or column value
- * @param parameter true if a parameter value was truncated
- * @param read true if a read was truncated
- * @param dataSize the original size of the data
- * @param transferSize the size after truncation
- */
- public DataTruncation(int index, boolean parameter,
- boolean read, int dataSize,
- int transferSize) {
- super("Data truncation", "01004");
- this.index = index;
- this.parameter = parameter;
- this.read = read;
- this.dataSize = dataSize;
- this.transferSize = transferSize;
- DriverManager.println(" DataTruncation: index(" + index +
- ") parameter(" + parameter +
- ") read(" + read +
- ") data size(" + dataSize +
- ") transfer size(" + transferSize + ")");
- }
-
- /**
- * Get the index of the column or parameter that was truncated.
- *
- * <P>This may be -1 if the column or parameter index is unknown, in
- * which case the "parameter" and "read" fields should be ignored.
- *
- * @return the index of the truncated paramter or column value.
- */
- public int getIndex() {
- return index;
- }
-
- /**
- * Is this a truncated parameter value?
- *
- * @return True if the value was a parameter; false if it was a column value.
- */
- public boolean getParameter() {
- return parameter;
- }
-
- /**
- * Was this a read truncation?
- *
- * @return True if the value was truncated when read from the database; false
- * if the data was truncated on a write.
- */
- public boolean getRead() {
- return read;
- }
-
- /**
- * Get the number of bytes of data that should have been transferred.
- * This number may be approximate if data conversions were being
- * performed. The value may be "-1" if the size is unknown.
- *
- * @return the number of bytes of data that should have been transferred
- */
- public int getDataSize() {
- return dataSize;
- }
-
- /**
- * Get the number of bytes of data actually transferred.
- * The value may be "-1" if the size is unknown.
- *
- * @return the number of bytes of data actually transferred
- */
- public int getTransferSize() {
- return transferSize;
- }
-
- private int index;
- private boolean parameter;
- private boolean read;
- private int dataSize;
- private int transferSize;
-
- }
-